package xufei.user.service.impl;

import com.xufei.common.domain.user.User;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import xufei.user.mapper.UserMapper;
import xufei.user.service.UserService;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    private final UserMapper userMapper;

    /**
     * 构造方法注入
     * @param userMapper
     */
    public UserServiceImpl(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public List<User> selectUserList(User user) {
        List<User> users = userMapper.selectUserList(user);
        return users;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateIntegral(User user) {
        userMapper.updateIntegral(user);
    }

    @Override
    public User selectUserByUsername(String userName) {
        User user = userMapper.selectUserByUsername(userName);
        return user;
    }
}
